/*
 * @Author: Aro
 * @Date: 2024-02-04 09:42:38
 */
// 可以 横向 / 竖向 滚动的列表
import 'package:flutter/material.dart';

// typedef WF = Widget Function(BuildContext context, int index);

class ListViewKit extends StatelessWidget {
  const ListViewKit({
    super.key,
    required this.itemFn,
    this.itemSepFn = defaultSepItem,
    this.direction = Axis.vertical,
    this.itemCount = 0,
  });

  final Widget Function(BuildContext context, int index) itemFn;
  final Widget Function(BuildContext context, int index) itemSepFn;
  final Axis direction;
  final int itemCount;

  static Container defaultSepItem(BuildContext context, int index) {
    return Container(
      color: Colors.white,
      height: 1,
      width: 1,
    );
  }

  @override
  Widget build(BuildContext context) {
    return ListView.separated(
      scrollDirection: direction,
      physics: const BouncingScrollPhysics(),
      padding: const EdgeInsets.all(0),
      itemCount: itemCount,
      itemBuilder: itemFn,
      separatorBuilder: itemSepFn,
    );
  }
}
